import EventBus from "../EventBus/index"

export function getPropsList(attr = []){
  const props = {}
  attr.forEach(item => {
    props[item.fieldName] = {
      type: item.dataType,
      default: item.initialValue,
      require: !!item.require
    }
  })
  return props
}

export function resetAttr(store, fieldName, value, initValue){
  // 清空初始值
  const {selectedComponent} = store.state.lowCode
  selectedComponent.props[fieldName] = value
  selectedComponent.props.value = initValue
  store.commit("lowCode/setSelectedComponent", selectedComponent)
  EventBus.$emit("setSelectComponentUpdateList", {})
}
